
{use if and for statement}
program bubbleSort;

type
	arrayType = array[0..100] of integer;
var
	a:arrayType;
	size:integer;{数组大小}
	i:integer;
procedure bubble();

var 
	j,temp:integer;
	aj,aj_1:integer;
begin
	for i:=0 to size-1 do
	begin
		for j:=0 to size - i -1 do
		begin
			aj:=a[j];
			aj_1:=a[j+1];
			if aj>aj_1 then temp:=a[j];
			if aj>aj_1 then a[j]:=a[j+1];
			if aj>aj_1 then a[j+1]:=temp;
		end;	
	end;

end;

begin
	writeln('Input size:');
	readln(size);
	writeln('Input all element[one element per row]:');
	for i:=0 to size do
	begin
		readln(a[i]);
	end;
	
	bubble();
	writeln('Sorted result is:');
	for i:=0 to size do
        begin
                  writeln(a[i]);
        end;
end.
